import Vue from 'vue'
import Router from 'vue-router'
Vue.use(Router)
    //app整体由店面页和店内页组成 暂时并没有用到嵌套路由
const routes=[
  {
    path: '/',
    name: "首页",
    component:
      resolve => require(["../components/home/home.vue"], resolve),
  },
  {
    path: '/category',
    name: "分类",
    components: {
      "default": resolve => require(["../components/category/category.vue"], resolve),
      // "subPage": resolve => require(["../components/categroy/categroy.vue"], resolve)
    }
  },
  {
    path: '/cart',
    name: "购物车",
    components: {
      "default": resolve => require(["../components/cart/cart.vue"], resolve),
      // "subPage": resolve => require(["../components/cart/cart.vue"], resolve)
    }
  },
  {
    path: '/category/:infoid',
    name: "商品详情",
    components: {
      "default": resolve => require(["../components/category/category.vue"], resolve),
      "subPage": resolve => require(["../components/goodinfo/info.vue"], resolve)
    }
  },
  {
    path: '/mine',
    name: "我的",
    components: {
      "default": resolve => require(["../components/mine/mine.vue"], resolve),
      // "subPage": resolve => require(["../components/wechat/dialogue.vue"], resolve)
    }
  },
  {
    path: '/order',
    name: "订单",
    components: {
      "default": resolve => require(["../components/order/order.vue"], resolve),
      // "subPage": resolve => require(["../components/wechat/dialogue.vue"], resolve)
    }
  },{
    path: '/search/search',
    name: "搜索",
    components: {
      "default": resolve => require(["../components/home/home.vue"], resolve),
      "subPage": resolve => require(["../components/search/search.vue"], resolve)
    }
  },
  {
    path: '/search/result',
    name: "搜索结果",
    components: {
      "default": resolve => require(["../components/search/search.vue"], resolve),
      "subPage": resolve => require(["../components/search/result.vue"], resolve)
    }
  },
]



export default new Router({
    base: "/vue-wechat/",
    routes,
    // scrollBehavior(to, from, savedPosition) {
    //     if (savedPosition) {
    //         return savedPosition
    //     } else {
    //         return { x: 0, y: 0 }
    //     }
    // }

})
